import AppKit

func globalMaxY() -> CGFloat {
    return NSScreen.screens.map { $0.frame.maxY }.max() ?? 0
}

func toBottomLeft(pointTopLeft: CGPoint, size: CGSize, topY: CGFloat) -> CGPoint {
    let yBL = topY - (pointTopLeft.y + size.height)
    return CGPoint(x: pointTopLeft.x, y: yBL)
}

func toBottomLeft(pointTopLeft: CGPoint, size: CGSize) -> CGPoint {
    let topY = globalMaxY()
    let yBL = topY - (pointTopLeft.y + size.height)
    return CGPoint(x: pointTopLeft.x, y: yBL)
}

func rectTopLeftToBottomLeft(originTopLeft: CGPoint, size: CGSize, topY: CGFloat) -> CGRect {
    let originBL = toBottomLeft(pointTopLeft: originTopLeft, size: size, topY: topY)
    return CGRect(origin: originBL, size: size)
}

func rectTopLeftToBottomLeft(originTopLeft: CGPoint, size: CGSize) -> CGRect {
    let originBL = toBottomLeft(pointTopLeft: originTopLeft, size: size)
    return CGRect(origin: originBL, size: size)
}
